<template>
  <div class="mod-config">
    <basic-container>
      <el-form :inline="true" :model="dataForm" @keyup.enter.native="getDataList()">
      </el-form>

      <div class="avue-crud">
        <el-table
                :data="dataList"
                border
                v-loading="dataListLoading">

                      <el-table-column
                    prop="topicName"
                    header-align="center"
                    align="center"
                    label="topic名称">
            </el-table-column>

                    <el-table-column
                  header-align="center"
                  align="center"
                  label="操作">
            <template slot-scope="scope">
              <el-button  type="text" size="small" icon="el-icon-delete" @click="deleteHandle(scope.row.topicName)">删除</el-button>
            </template>
          </el-table-column>
        </el-table>
      </div>

    </basic-container>
  </div>
</template>

<script>
  import {fetchList,delObj} from '@/api/bus/topic'
  import {mapGetters} from 'vuex'
  export default {
    data () {
      return {
        dataList: [],
        dataListLoading: false,

      }
    },
    created () {
      this.getDataList()
    },
    computed: {
      ...mapGetters(['permissions'])
    },
    methods: {
      // 获取数据列表
      getDataList () {
        this.dataListLoading = true
        fetchList().then(response => {
          this.dataList = response.data.data
        })
        this.dataListLoading = false
      },
      // 删除
      deleteHandle (topicName) {
        this.$confirm('是否确认删除topic为' + topicName, '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(function () {
          return delObj(topicName)
        }).then(data => {
          this.$message.success('删除成功')
          this.getDataList()
        }).catch(() => {})
      }
    }
  }
</script>
